FROM ubuntu:14.04
MAINTAINER Brick Yang <brick.yang@printfxxx.com>

ARG DEBIAN_FRONTEND=noninteractive
ARG APT_MIRROR_URL=archive.ubuntu.com

RUN cp /etc/apt/sources.list /etc/apt/sources.list.orig
RUN sed -i -e "s/archive.ubuntu.com/$APT_MIRROR_URL/g" /etc/apt/sources.list

RUN dpkg --add-architecture i386
RUN rm -rf /var/lib/apt/lists/*
RUN apt-get autoclean && apt-get autoremove && apt-get update --fix-missing && apt-get upgrade --fix-missing -y \
	&& apt-get dist-upgrade --fix-missing -y && apt-get install -y apt-utils sudo locales
RUN echo 'dash dash/sh boolean false' | debconf-set-selections && dpkg-reconfigure dash
RUN locale-gen --lang en_US.UTF-8 && echo 'LANG=en_US.UTF-8' > /etc/default/locale
RUN passwd -d root

RUN apt-get install -y openssh-server vim xfce4 xfce4-terminal	\
	xubuntu-icon-theme gnome-icon-theme tango-icon-theme x11vnc xvfb
RUN apt-get install -y libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386 libgtk2.0-0:i386	\
	libxpm4:i386 libusb-0.1-4:i386 libusb-1.0-0:i386 libuuid1:i386 libxcb1:i386 libnspr4:i386 libglib2.0-0:i386	\
	libxdamage1:i386 libxtst6:i386 libssl0.9.8:i386 libssl1.0.0:i386 make firefox usbutils
RUN echo 'UseDNS no' >> /etc/ssh/sshd_config

ADD myvnc /etc/init.d/myvnc
RUN chmod a+x /etc/init.d/myvnc
ADD myvnc.sh /usr/local/bin/myvnc.sh
RUN chmod a+x /usr/local/bin/myvnc.sh
ADD startup.sh /usr/local/bin/startup.sh
RUN chmod a+x /usr/local/bin/startup.sh
ADD init.sh /usr/local/bin/init.sh
RUN chmod a+x /usr/local/bin/init.sh

ENTRYPOINT ["/usr/local/bin/startup.sh"]

EXPOSE 22
EXPOSE 5900
